package com.lmx.repoDomain.tmodel;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToMany;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

/**
 * 风险评估模板
 *
 * @author ytche
 * @date 2017年8月2日
 *
 */
@Entity
@JsonApiResource(type = "riskAssessModel")
@Table(name = "TNB_RISK_ASSESS_MODEL")
public class RiskAssessModel extends BaseEntity {

	private static final long serialVersionUID = 1L;
	private String name;
	private String remark;
	private Integer createTime;
	private Set<EvaluateModel> evaluateModels;
	private Set<RiskLevel> levels;
	private Set<RiskRecordModel> riskRecordModels;
	private String code;

	@Column(name = "name")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Column(name = "create_time")
	public Integer getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Integer createTime) {
		this.createTime = createTime;
	}

	@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH, mappedBy = "assess")
	@Fetch(FetchMode.JOIN)
	@JsonApiToMany
	@JsonApiIncludeByDefault
	public Set<RiskLevel> getLevels() {
		return levels;
	}

	public void setLevels(Set<RiskLevel> levels) {
		this.levels = levels;
	}

	@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH, mappedBy = "riskModel")
	@Fetch(FetchMode.JOIN)
	@JsonApiToMany
	@JsonApiIncludeByDefault
	public Set<RiskRecordModel> getRiskRecordModels() {
		return riskRecordModels;
	}

	public void setRiskRecordModels(Set<RiskRecordModel> riskRecordModels) {
		this.riskRecordModels = riskRecordModels;
	}

	@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH, mappedBy = "riskAssessModel")
	@Fetch(FetchMode.JOIN)
	@JsonApiToMany
	@JsonApiIncludeByDefault
	public Set<EvaluateModel> getEvaluateModels() {
		return evaluateModels;
	}

	public void setEvaluateModels(Set<EvaluateModel> evaluateModels) {
		this.evaluateModels = evaluateModels;
	}

	@Column(name = "code")
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

}
